package com.heima.search.controller;

import com.heima.apis.search.SearchControllerApi;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.search.dtos.UserSearchDto;
import com.heima.search.service.SearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

@RestController
@RequestMapping("/api/v1/search")
public class SearchController implements SearchControllerApi {

    @Autowired
    SearchService searchService;

    /**
     * 根据关键词搜索
     * @param dto
     * @return
     */
    @PostMapping("/search")
    @Override
    public ResponseResult search(@RequestBody UserSearchDto dto) throws Exception {

        return searchService.search(dto);
    }
}
